<!-- @hadeer ahmed

this page shows the chosen exercise in text boxes to get edited by the creator of exercise -->
#{extends 'main.html' /} #{set title:'Home' /}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
	function show_alert() {
		alert("you have edited the exercise successfully !");
	}
</script>
<script>
	function generatenew() {
		var d = document.getElementById("div1");
		d.innerHTML += "<p>choice:<input type='text' name='Choices'>";
	}
</script>
<script>
	function generatenewoption() {
		var d = document.getElementById("div");
		d.innerHTML += "<p>choice:<input type='text' name='newChoices'>";
	}
</script>
</head>
<body>


	<form id="myForm" name="input" action="@{Exercises.submitEdit()}"
		method="post">

		<h2 align="center">Edit exercise</h2>


		#{list items:theQuestions, as:'question'}

		<ul>
			the Question:
			<span style="color: #c00" class="error">#{error 'theQuestion'
				/}</span>
			<br>
			<input type="text" id="theQuestion" name="theQuestion"
				value="${question.theQuestion}" />
			<br>
		</ul>
		#{list items:question.myChoices, as:'listchoices'}
		<div id="div1">
			<ul>

				<input type="text" id="Choice" name="Choice"
					value="${listchoices.choice}" />
				<br>

			</ul>
		</div>
		#{/list}

		<ul>
			marks:
			<span style="color: #c00" class="error">#{error 'marks' /}</span>
			<br>
			<input type="text" id="marks" name="marks" value="${question.marks}" />
			<br>
		</ul>
<button name="delete" id="delete" type="submit" value="${question.id}">delete question</button>
		#{/list} <input style="visibility: hidden;" type="text"
			id="exerciseid" name="exerciseid" value=${tempExercise.id} /><br>
		<button name="edit" id="edit" type="submit" value="Show alert box">edit</button>
	</form>

	<form id="myForm" name="input" action="@{Exercises.createQuestion()}"
		method="post">
		<div id="div">
			<input style="visibility: hidden;" type="text" id="exerciseid"
				name="exerciseid" value=${tempExercise.id} /><br> <span
				style="color: #c00" class="error">#{error 'theQuestion' /}</span><br>
			the question :<input type="text" id="theQuestion" name="theQuestion" /><br>
			choice 1:<input type="text" id="Choice1" name="Choice1" /><br>
			choice 2:<input type="text" id="Choice2" name="Choice2" /><br>
			choice 3:<input type="text" id="Choice3" name="Choice3" /><br>
		</div>
		<span style="color: #c00" class="error">#{error 'Marks' /}</span><br>
		marks per question:<input type="text" id="Marks" name="Marks" /><br>


		<button name="editQuestion" id="editQuestion" type="submit"
			onclick="checkNull()" value="${tempExercise.id}">add
			question</button>


	</form>
	<button name="addoption" id="addoption" type="submit" value="new"
		onclick="generatenewoption()">add option</button>

</body>
</html>